package com.securitytrace.client.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.securitytrace.client.cache.SystemInfoCache;

public class LoginFrame extends BaseFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3114236790056742963L;

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JTextField accountTextField;
	private javax.swing.JLabel copyrightLabel;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JPanel jPanel1;
	private javax.swing.JPanel jPanel2;
	private javax.swing.JSeparator jSeparator1;
	private javax.swing.JSeparator jSeparator2;
	private javax.swing.JButton loginButton;
	private javax.swing.JPasswordField passwordField;
	private javax.swing.JButton resetButton;
	private javax.swing.JLabel titleLabel;
	private javax.swing.JLabel versionLabel;
	// End of variables declaration//GEN-END:variables
	
//	public static final ConfigInfo configInfo = ConfigInfo.getInstance();
	
	/** Creates new form LoginFrame */
	public LoginFrame() {
		initComponents();
		super.setCenter();
		setVisible(true);
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	private void initComponents() {

		jPanel1 = new javax.swing.JPanel();
		jSeparator1 = new javax.swing.JSeparator();
		jSeparator2 = new javax.swing.JSeparator();
		jPanel2 = new javax.swing.JPanel();
		accountTextField = new javax.swing.JTextField();
		jLabel1 = new javax.swing.JLabel();
		jLabel2 = new javax.swing.JLabel();
		loginButton = new javax.swing.JButton();
		resetButton = new javax.swing.JButton();
		passwordField = new javax.swing.JPasswordField();
		titleLabel = new javax.swing.JLabel();
		versionLabel = new javax.swing.JLabel();
		copyrightLabel = new javax.swing.JLabel();

		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setTitle(SystemInfoCache.LOGINFRAMETITLE);
		
		jLabel1.setText("账号");

		jLabel2.setText("密码");
		
		passwordField.setEchoChar('*');

		loginButton.setText("登录");

		resetButton.setText("重置");
		resetButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				resetButtonActionPerformed(e);
			}
		});

		javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(
				jPanel2);
		jPanel2.setLayout(jPanel2Layout);
		jPanel2Layout
				.setHorizontalGroup(jPanel2Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel2Layout
										.createSequentialGroup()
										.addGap(58, 58, 58)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(jLabel1)
														.addComponent(jLabel2))
										.addGap(27, 27, 27)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																passwordField,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																210,
																Short.MAX_VALUE)
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																jPanel2Layout
																		.createSequentialGroup()
																		.addComponent(
																				loginButton)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																				96,
																				Short.MAX_VALUE)
																		.addComponent(
																				resetButton))
														.addComponent(
																accountTextField,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																210,
																Short.MAX_VALUE))
										.addContainerGap(61, Short.MAX_VALUE)));
		jPanel2Layout
				.setVerticalGroup(jPanel2Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel2Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																accountTextField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(jLabel1))
										.addGap(34, 34, 34)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(jLabel2)
														.addComponent(
																passwordField,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												28, Short.MAX_VALUE)
										.addGroup(
												jPanel2Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																resetButton)
														.addComponent(
																loginButton))
										.addGap(25, 25, 25)));

		titleLabel.setFont(new java.awt.Font("黑体", 0, 24)); // NOI18N
		titleLabel.setText(SystemInfoCache.TITLE);

		versionLabel.setFont(new java.awt.Font("宋体", 2, 14)); // NOI18N
		versionLabel.setText(SystemInfoCache.VERSINO);

		copyrightLabel.setFont(new java.awt.Font("宋体", 0, 14)); // NOI18N
		copyrightLabel.setText(SystemInfoCache.COPYRIGHT);
		copyrightLabel
				.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

		javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(
				jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout
				.setHorizontalGroup(jPanel1Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(titleLabel)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(versionLabel)
										.addGap(104, 104, 104))
						.addComponent(jSeparator1,
								javax.swing.GroupLayout.PREFERRED_SIZE, 402,
								javax.swing.GroupLayout.PREFERRED_SIZE)
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												jPanel2,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap(12, Short.MAX_VALUE))
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addComponent(
												jSeparator2,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												401, Short.MAX_VALUE)
										.addGap(1, 1, 1))
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												copyrightLabel,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												372,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addContainerGap(20, Short.MAX_VALUE)));
		jPanel1Layout
				.setVerticalGroup(jPanel1Layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								jPanel1Layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												jPanel1Layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																titleLabel,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																41,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																versionLabel))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jSeparator1,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												10,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jPanel2,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(
												jSeparator2,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(copyrightLabel)
										.addContainerGap(
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
				javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
		layout.setVerticalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
				javax.swing.GroupLayout.DEFAULT_SIZE,
				javax.swing.GroupLayout.PREFERRED_SIZE));

		pack();
	}// </editor-fold>//GEN-END:initComponents

	public void addLoginButtonActionListener(ActionListener listener) {
		loginButton.addActionListener(listener);
	}

	public void resetButtonActionPerformed(ActionEvent event) {
		this.accountTextField.setText("");
		this.passwordField.setText("");
	}
	
	public javax.swing.JTextField getAccountTextField() {
		return accountTextField;
	}

	public javax.swing.JPasswordField getPasswordField() {
		return passwordField;
	}
	
	
	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {

			public void run() {
				new LoginFrame().setVisible(true);
			}
		});
	}

}
